$(function () {
    const pro1 = new Promise((resolve, reject) => {
        $.ajax(`${baseUrl}/categories/count`, {
            success: res => resolve(res),
            error: err => reject(err),
        })
    })
    const pro2 = new Promise((resolve, reject) => {
        $.ajax(`${baseUrl}/posts/count`, {
            success: res => resolve(res),
            error: err => reject(err),
        })
    })
    const pro3 = new Promise((resolve, reject) => {
        $.ajax(`${baseUrl}/comments/count`, {
            success: res => resolve(res),
            error: err => reject(err),
        })
    })
    Promise.all([pro1, pro2, pro3])
        .then(res => {
            let objTemp = {}
            res.forEach(item => {
                for (let key in item) {
                    objTemp[key] = item[key]
                }
            })
            // console.log(objTemp)
            const newHtml = template("pageCount", objTemp)
            // console.log(newHtml)
            $(".count-page").html(newHtml)
        })
        .catch(err => console.log(err))
})
